/*
 * TcpTest.cpp
 *
 *  Created on: Dec 31, 2013
 *      Author: slava
 */

#include <iostream>
#include "cm_net.h"
#include <fstream>
#include <sstream>

using std::cout;
using std::cin;
using std::endl;
using std::fstream;
using std::istringstream;

int main(int argc, char* argv[]) {
	try {
		cout << "Setting up client" << endl;
		TcpChannel tcp_client(argv[1], atoi(argv[2]));
		cout << "Client is up and connected" << endl;
		string filename("test_in.txt");
		fstream fd(filename.c_str(), std::fstream::in);
		cout << "Sending to server" << endl;
		tcp_client.write_from(fd);
		cout << "Waiting for response from server" << endl;
		tcp_client.read_into(cout);
		cout << "server got and responded" << endl;
		fd.close();
	} catch (ConnectionError& e) {
		cout << e.what << " Terminating client" << endl;
	}
	return 0;

}
/*
 * TcpTestCli.cpp
 *
 *  Created on: Dec 31, 2013
 *      Author: slava
 */

